package ldh.im.base.service;

import ldh.im.ImConfig;
import ldh.im.base.ImSession;
import ldh.im.dto.business.ExitReq;
import ldh.im.dto.business.ExitResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExitHandlerService implements BusinessService<ExitReq> {

    private static final Logger LOGGER = LoggerFactory.getLogger(ExitHandlerService.class);

    @Override
    public void handle(ImSession imSession, ExitReq exitReq) {
        ExitResp exitResponse = new ExitResp(exitReq.getLocalSeq());
        imSession.getChannel().writeAndFlush(exitResponse);
        imSession.getChannel().close();

        LOGGER.info("{} exit {}", imSession.get(ImConfig.USER_ID), imSession.getChannel());
    }
}
